package com.taobao.ui.widget;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

import com.swtdesigner.SWTResourceManager;
import com.taobao.action.OpenSmallerUIAction;
import com.taobao.action.UserInfoAction;
import com.taobao.action.UserInfoSmallerAction;
import com.taobao.action.ui.LabelCursorAction;
import com.taobao.pojo.UserInfo;
import com.taobao.tools.Binding;
import com.taobao.tools.GIF;
import com.taobao.ui.SmallerUI;

public class UserInfoWidget extends CommonWidget {
	private Text text;
	private Text text_1;
	private Text text_2;
	private Text text_3;
	private Text text_4;
	private Text text_5;
	private Text text_6;
	private Label waitGif;
	private Label label_11;

	private UserInfoAction userInfoAction = new UserInfoAction();
	private UserInfoSmallerAction userInfoSmallerAction = new UserInfoSmallerAction();
	private OpenSmallerUIAction openSmallerUIAction = new OpenSmallerUIAction();
	public static final String ID = "com.taobao.ui.widget.UserInfoWidget";
	@Override
	public String getID() {
		return UserInfoWidget.ID;
	}

	/**
	 * Create the composite.
	 * 
	 * @param parent
	 * @param style
	 */
	public UserInfoWidget(Composite parent, int style) {
		super(parent, style);
		GridLayout gridLayout_5 = new GridLayout(1, false);
		gridLayout_5.marginHeight = 0;
		gridLayout_5.marginWidth = 0;
		setLayout(gridLayout_5);

		Group group = new Group(this, SWT.NONE);
		group.setText("\u7528\u6237\u4FE1\u606F");
		GridLayout gridLayout_3 = new GridLayout(1, false);
		gridLayout_3.verticalSpacing = 0;
		group.setLayout(gridLayout_3);
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
		gridData.heightHint = 235;
		group.setLayoutData(gridData);

		Composite composite_10 = new Composite(group, SWT.NONE);
		composite_10.setLayout(new GridLayout(5, false));
		composite_10.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

		Label label_3 = new Label(composite_10, SWT.NONE);
		label_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		label_3.setText("\u5F53\u524D\u7528\u6237\uFF1A");

		text = new Text(composite_10, SWT.READ_ONLY);
		text.setEnabled(false);
		text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		Binding.binding(getThis(UserInfoWidget.class), text, Binding.GROUP_TEXT, UserInfo.class, "userName");

		Label label_1 = new Label(composite_10, SWT.NONE);
		GridData gridData_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
		gridData_1.widthHint = 0;
		label_1.setLayoutData(gridData_1);
		label_1.setAlignment(SWT.CENTER);

		Label label_2 = new Label(composite_10, SWT.NONE);
		label_2.setText("\u79EF\u5206\uFF1A");

		text_3 = new Text(composite_10, SWT.READ_ONLY);
		text_3.setEnabled(false);
		text_3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		Binding.binding(getThis(UserInfoWidget.class), text_3, Binding.GROUP_TEXT, UserInfo.class, "integral");

		Composite composite_11 = new Composite(group, SWT.NONE);
		composite_11.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

		Composite composite_12 = new Composite(group, SWT.NONE);
		composite_12.setLayout(new GridLayout(5, false));
		composite_12.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

		Label label_4 = new Label(composite_12, SWT.NONE);
		label_4.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		label_4.setText("\u8D26\u6237\u4F59\u989D\uFF1A");

		text_1 = new Text(composite_12, SWT.READ_ONLY);
		text_1.setEnabled(false);
		text_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		Binding.binding(getThis(UserInfoWidget.class), text_1, Binding.GROUP_TEXT, UserInfo.class, "money");

		Label label_6 = new Label(composite_12, SWT.NONE);
		GridData gridData_2 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
		gridData_2.widthHint = 0;
		label_6.setLayoutData(gridData_2);

		Label label_7 = new Label(composite_12, SWT.NONE);
		label_7.setText("\u7B49\u7EA7\uFF1A");

		text_4 = new Text(composite_12, SWT.READ_ONLY);
		text_4.setEnabled(false);
		text_4.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		Binding.binding(getThis(UserInfoWidget.class), text_4, Binding.GROUP_IMAGE, UserInfo.class, "levelImage");

		Composite composite_13 = new Composite(group, SWT.NONE);
		composite_13.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

		Composite composite_14 = new Composite(group, SWT.NONE);
		composite_14.setLayout(new GridLayout(5, false));
		composite_14.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

		Label label_5 = new Label(composite_14, SWT.NONE);
		label_5.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		label_5.setText("\u53D1  \u5E03 \u70B9\uFF1A");

		text_2 = new Text(composite_14, SWT.READ_ONLY);
		text_2.setEnabled(false);
		text_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		Binding.binding(getThis(UserInfoWidget.class), text_2, Binding.GROUP_TEXT, UserInfo.class, "pPoint");

		Label label_8 = new Label(composite_14, SWT.NONE);
		GridData gridData_3 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
		gridData_3.widthHint = 0;
		label_8.setLayoutData(gridData_3);

		Label label_9 = new Label(composite_14, SWT.NONE);
		label_9.setText("\u8B66\u544A\uFF1A");

		text_5 = new Text(composite_14, SWT.READ_ONLY);
		text_5.setEnabled(false);
		text_5.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		Binding.binding(getThis(UserInfoWidget.class), text_5, Binding.GROUP_TEXT, UserInfo.class, "warning");

		Composite composite_15 = new Composite(group, SWT.NONE);
		composite_15.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

		Composite composite_16 = new Composite(group, SWT.NONE);
		composite_16.setLayout(new GridLayout(6, false));
		composite_16.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

		Label label = new Label(composite_16, SWT.NONE);
		label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		label.setText("\u5C0F\u53F7\u6570\u91CF\uFF1A");

		text_6 = new Text(composite_16, SWT.READ_ONLY);
		text_6.setEnabled(false);
		GridData gridData_5 = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
		gridData_5.widthHint = 50;
		text_6.setLayoutData(gridData_5);
		Binding.binding(getThis(UserInfoWidget.class), text_6, Binding.GROUP_LIST_SIZE, UserInfo.class, "smallers");

		Label label_10 = new Label(composite_16, SWT.NONE);
		GridData gridData_4 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
		gridData_4.widthHint = 0;
		label_10.setLayoutData(gridData_4);

		label_11 = new Label(composite_16, SWT.NONE);
		label_11.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
		label_11.setText(">>\u9AD8\u7EA7  ");
		LabelCursorAction labelCursorAction0 = new LabelCursorAction(openSmallerUIAction, getThis(UserInfoWidget.class));
		label_11.addMouseTrackListener(labelCursorAction0);
		label_11.addMouseListener(labelCursorAction0);
		label_11.setEnabled(false);

		Label label_12 = new Label(composite_16, SWT.NONE);
		label_12.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
		label_12.setText(">>\u5237\u65B0  ");
		LabelCursorAction labelCursorAction = new LabelCursorAction(userInfoSmallerAction, getThis(UserInfoWidget.class));
		label_12.addMouseTrackListener(labelCursorAction);
		label_12.addMouseListener(labelCursorAction);

		waitGif = new Label(composite_16, SWT.NONE);
		GridData gridData_6 = new GridData(SWT.LEFT, SWT.BOTTOM, false, false, 1, 1);
		gridData_6.heightHint = 14;
		gridData_6.widthHint = 43;
		waitGif.setLayoutData(gridData_6);
		new GIF().gif(waitGif, getShell(), "code.gif");

		userInfoAction.doAction(getThis(UserInfoWidget.class));
	}

	public void showWaitGif() {
		waitGif.setVisible(true);
		label_11.setEnabled(false);
	}

	public void hideWaitGif() {
		waitGif.setVisible(false);
		label_11.setEnabled(true);
	}

	public void openSmallerUI() {
		SmallerUI smallerUI = new SmallerUI(getShell(), getPojo(UserInfo.class));
		smallerUI.setBlockOnOpen(true);
		smallerUI.open();
	}
}
